home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / SoundComponents.p < prev    next >
Encoding:
Text File  |  1994-11-11  |  13.6 KB  |  352 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        SoundComponents.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT SoundComponents;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __SOUNDCOMPONENTS__}
  27. {$SETC __SOUNDCOMPONENTS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC SoundComponentsIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __COMPONENTS__}
  40. {$I Components.p}
  41. {$ENDC}
  42. {    MixedMode.p                                                    }
  43.  
  44. {$IFC UNDEFINED __SOUND__}
  45. {$I Sound.p}
  46. {$ENDC}
  47.  
  48. {$PUSH}
  49. {$ALIGN MAC68K}
  50. {$LibExport+}
  51. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  52. { constants}
  53. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  54.  
  55. CONST
  56. {sound component set/get info selectors}
  57.     siVolume                    = 'volu';
  58.     siHardwareVolume            = 'hvol';
  59.     siSpeakerVolume                = 'svol';
  60.     siHeadphoneVolume            = 'pvol';
  61.     siHardwareVolumeSteps        = 'hstp';
  62.     siHeadphoneVolumeSteps        = 'hdst';
  63.     siHardwareMute                = 'hmut';
  64.     siSpeakerMute                = 'smut';
  65.     siHeadphoneMute                = 'pmut';
  66.     siRateMultiplier            = 'rmul';
  67.     siQuality                    = 'qual';
  68. {format types}
  69.     kOffsetBinary                = 'raw ';
  70.     kTwosComplement                = 'twos';
  71.     kMACE3Compression            = 'MAC3';
  72.     kMACE6Compression            = 'MAC6';
  73.  
  74. {quality flags}
  75. {use interpolation in rate conversion}
  76.     kBestQuality                = 0+(1 * (2**(0)));
  77.  
  78. {useful bit masks}
  79.     kInputMask                    = $000000FF;                    {masks off input bits}
  80.     kOutputMask                    = $0000FF00;                    {masks off output bits}
  81.     kOutputShift                = 8;                            {amount output bits are shifted}
  82.     kActionMask                    = $00FF0000;                    {masks off action bits}
  83.     kSoundComponentBits            = $00FFFFFF;
  84.  
  85. {SoundComponentPlaySourceBuffer action flags}
  86.     kSourcePaused                = 0+(1 * (2**(0)));
  87.     kPassThrough                = 0+(1 * (2**(16)));
  88.     kNoSoundComponentChain        = 0+(1 * (2**(17)));
  89. {flags for OpenMixerSoundComponent}
  90.     kNoMixing                    = 0+(1 * (2**(0)));                {don't mix source}
  91.     kNoSampleRateConversion        = 0+(1 * (2**(1)));                {don't convert sample rate (i.e. 11 kHz -> 22 kHz)}
  92.     kNoSampleSizeConversion        = 0+(1 * (2**(2)));                {don't convert sample size (i.e. 16 -> 8)}
  93.     kNoSampleFormatConversion    = 0+(1 * (2**(3)));                {don't convert sample format (i.e. 'twos' -> 'raw ')}
  94.     kNoChannelConversion        = 0+(1 * (2**(4)));                {don't convert stereo/mono}
  95.     kNoDecompression            = 0+(1 * (2**(5)));                {don't decompress (i.e. 'MAC3' -> 'raw ')}
  96.     kNoVolumeConversion            = 0+(1 * (2**(6)));                {don't apply volume}
  97.     kNoRealtimeProcessing        = 0+(1 * (2**(7)));                {won't run at interrupt time}
  98.  
  99. {Audio Component constants}
  100. {Values for whichChannel parameter}
  101.     audioAllChannels            = 0;                            {All channels (usually interpreted as both left and right)}
  102.     audioLeftChannel            = 1;                            {Left channel}
  103.     audioRightChannel            = 2;                            {Right channel}
  104. {Values for mute parameter}
  105.     audioUnmuted                = 0;                            {Device is unmuted}
  106.     audioMuted                    = 1;                            {Device is muted}
  107. {Capabilities flags definitions}
  108.     audioDoesMono                = 0+(1 * (2**(0)));                {Device supports mono output}
  109.     audioDoesStereo                = 0+(1 * (2**(1)));                {Device supports stereo output}
  110.     audioDoesIndependentChannels = 0+(1 * (2**(2)));            {Device supports independent software control of each channel}
  111.  
  112. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  113. { typedefs}
  114. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  115. {ShortFixed consists of an 8 bit, 2's complement integer part in the high byte,}
  116. {with an 8 bit fractional part in the low byte; its range is -128 to 127.99609375}
  117.     
  118. TYPE
  119.     ShortFixed = INTEGER;
  120.  
  121.     SoundComponentDataPtr = ^SoundComponentData;
  122.  
  123.     SoundComponentData = RECORD
  124.         flags:                    LONGINT;
  125.         format:                    OSType;
  126.         numChannels:            INTEGER;
  127.         sampleSize:                INTEGER;
  128.         sampleRate:                UnsignedFixed;
  129.         sampleCount:            LONGINT;
  130.         buffer:                    ^Byte;
  131.         reserved:                LONGINT;
  132.     END;
  133.     SoundParamBlockPtr = ^SoundParamBlock;
  134.  
  135.     SoundParamProcPtr = ProcPtr;  { FUNCTION SoundParam(VAR pb: SoundParamBlockPtr): BOOLEAN; }
  136.     SoundParamUPP = UniversalProcPtr;
  137.  
  138.     SoundParamBlock = RECORD
  139.         recordSize:                LONGINT;                                {size of this record in bytes}
  140.         desc:                    SoundComponentData;                        {description of sound buffer}
  141.         rateMultiplier:            UnsignedFixed;                            {rate multiplier to apply to sound}
  142.         leftVolume:                INTEGER;                                {volumes to apply to sound}
  143.         rightVolume:            INTEGER;
  144.         quality:                LONGINT;                                {quality to apply to sound}
  145.         filter:                    ComponentInstance;                        {filter to apply to sound}
  146.         moreRtn:                SoundParamUPP;                            {routine to call to get more data}
  147.         completionRtn:            SoundParamUPP;                            {routine to call when buffer is complete}
  148.         refCon:                    LONGINT;                                {user refcon}
  149.         result:                    INTEGER;                                {result}
  150.     END;
  151.     SoundSource = Ptr;
  152.  
  153.     AudioInfo = RECORD
  154.         capabilitiesFlags:        LONGINT;                                {Describes device capabilities}
  155.         reserved:                LONGINT;                                {Reserved by Apple}
  156.         numVolumeSteps:            INTEGER;                                {Number of significant increments between min and max volume}
  157.     END;
  158.     AudioInfoPtr = ^AudioInfo;
  159.  
  160. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  161. { functions for sound components}
  162. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  163. {Sound Component dispatch selectors}
  164.  
  165. CONST
  166. {these calls cannot be delegated}
  167.     kSoundComponentInitOutputDeviceSelect = 1;
  168.     kSoundComponentSetSourceSelect = 2;
  169.     kSoundComponentGetSourceSelect = 3;
  170.     kSoundComponentGetSourceDataSelect = 4;
  171.     kSoundComponentSetOutputSelect = 5;
  172.     kDelegatedSoundComponentSelectors = $0100;                    {first selector that can be delegated up the chain}
  173. {these calls can be delegated and have own range}
  174.     kSoundComponentAddSourceSelect = kDelegatedSoundComponentSelectors + 1;
  175.     kSoundComponentRemoveSourceSelect = kDelegatedSoundComponentSelectors + 2;
  176.     kSoundComponentGetInfoSelect = kDelegatedSoundComponentSelectors + 3;
  177.     kSoundComponentSetInfoSelect = kDelegatedSoundComponentSelectors + 4;
  178.     kSoundComponentStartSourceSelect = kDelegatedSoundComponentSelectors + 5;
  179.     kSoundComponentStopSourceSelect = kDelegatedSoundComponentSelectors + 6;
  180.     kSoundComponentPauseSourceSelect = kDelegatedSoundComponentSelectors + 7;
  181.     kSoundComponentPlaySourceBufferSelect = kDelegatedSoundComponentSelectors + 8;
  182.  
  183. {Audio Component selectors}
  184.     kAudioGetVolumeSelect        = 0;
  185.     kAudioSetVolumeSelect        = 1;
  186.     kAudioGetMuteSelect            = 2;
  187.     kAudioSetMuteSelect            = 3;
  188.     kAudioSetToDefaultsSelect    = 4;
  189.     kAudioGetInfoSelect            = 5;
  190.     kAudioGetBassSelect            = 6;
  191.     kAudioSetBassSelect            = 7;
  192.     kAudioGetTrebleSelect        = 8;
  193.     kAudioSetTrebleSelect        = 9;
  194.     kAudioGetOutputDeviceSelect    = 10;
  195.     kAudioMuteOnEventSelect        = 129;
  196.  
  197. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  198. { Sound Manager 3.0 utilities}
  199.  
  200. FUNCTION OpenMixerSoundComponent(outputDescription: SoundComponentDataPtr; outputFlags: LONGINT; VAR mixerComponent: ComponentInstance): OSErr;
  201.     {$IFC NOT GENERATINGCFM}
  202.     INLINE $203C, $0614, $0018, $A800;
  203.     {$ENDC}
  204. FUNCTION CloseMixerSoundComponent(ci: ComponentInstance): OSErr;
  205.     {$IFC NOT GENERATINGCFM}
  206.     INLINE $203C, $0218, $0018, $A800;
  207.     {$ENDC}
  208. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  209. { basic sound component functions}
  210. FUNCTION SoundComponentInitOutputDevice(ti: ComponentInstance; actions: LONGINT): ComponentResult;
  211.     {$IFC NOT GENERATINGCFM}
  212.     INLINE $2F3C, 4, 1, $7000, $A82A;
  213.     {$ENDC}
  214. FUNCTION SoundComponentSetSource(ti: ComponentInstance; sourceID: SoundSource; source: ComponentInstance): ComponentResult;
  215.     {$IFC NOT GENERATINGCFM}
  216.     INLINE $2F3C, 8, 2, $7000, $A82A;
  217.     {$ENDC}
  218. FUNCTION SoundComponentGetSource(ti: ComponentInstance; sourceID: SoundSource; VAR source: ComponentInstance): ComponentResult;
  219.     {$IFC NOT GENERATINGCFM}
  220.     INLINE $2F3C, 8, 3, $7000, $A82A;
  221.     {$ENDC}
  222. FUNCTION SoundComponentGetSourceData(ti: ComponentInstance; VAR sourceData: SoundComponentDataPtr): ComponentResult;
  223.     {$IFC NOT GENERATINGCFM}
  224.     INLINE $2F3C, 4, 4, $7000, $A82A;
  225.     {$ENDC}
  226. FUNCTION SoundComponentSetOutput(ti: ComponentInstance; requested: SoundComponentDataPtr; VAR actual: SoundComponentDataPtr): ComponentResult;
  227.     {$IFC NOT GENERATINGCFM}
  228.     INLINE $2F3C, 8, 5, $7000, $A82A;
  229.     {$ENDC}
  230. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  231. { junction methods for the mixer, must be called at non-interrupt level}
  232. FUNCTION SoundComponentAddSource(ti: ComponentInstance; VAR sourceID: SoundSource): ComponentResult;
  233.     {$IFC NOT GENERATINGCFM}
  234.     INLINE $2F3C, 4, $0101, $7000, $A82A;
  235.     {$ENDC}
  236. FUNCTION SoundComponentRemoveSource(ti: ComponentInstance; sourceID: SoundSource): ComponentResult;
  237.     {$IFC NOT GENERATINGCFM}
  238.     INLINE $2F3C, 4, $0102, $7000, $A82A;
  239.     {$ENDC}
  240. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  241. { info methods}
  242. FUNCTION SoundComponentGetInfo(ti: ComponentInstance; sourceID: SoundSource; selector: OSType; infoPtr: UNIV Ptr): ComponentResult;
  243.     {$IFC NOT GENERATINGCFM}
  244.     INLINE $2F3C, 12, $0103, $7000, $A82A;
  245.     {$ENDC}
  246. FUNCTION SoundComponentSetInfo(ti: ComponentInstance; sourceID: SoundSource; selector: OSType; infoPtr: UNIV Ptr): ComponentResult;
  247.     {$IFC NOT GENERATINGCFM}
  248.     INLINE $2F3C, 12, $0104, $7000, $A82A;
  249.     {$ENDC}
  250. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  251. { control methods}
  252. FUNCTION SoundComponentStartSource(ti: ComponentInstance; count: INTEGER; VAR sources: SoundSource): ComponentResult;
  253.     {$IFC NOT GENERATINGCFM}
  254.     INLINE $2F3C, 6, $0105, $7000, $A82A;
  255.     {$ENDC}
  256. FUNCTION SoundComponentStopSource(ti: ComponentInstance; count: INTEGER; VAR sources: SoundSource): ComponentResult;
  257.     {$IFC NOT GENERATINGCFM}
  258.     INLINE $2F3C, 6, $0106, $7000, $A82A;
  259.     {$ENDC}
  260. FUNCTION SoundComponentPauseSource(ti: ComponentInstance; count: INTEGER; VAR sources: SoundSource): ComponentResult;
  261.     {$IFC NOT GENERATINGCFM}
  262.     INLINE $2F3C, 6, $0107, $7000, $A82A;
  263.     {$ENDC}
  264. FUNCTION SoundComponentPlaySourceBuffer(ti: ComponentInstance; sourceID: SoundSource; pb: SoundParamBlockPtr; actions: LONGINT): ComponentResult;
  265.     {$IFC NOT GENERATINGCFM}
  266.     INLINE $2F3C, 12, $0108, $7000, $A82A;
  267.     {$ENDC}
  268. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  269. { interface for Audio Components}
  270. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  271. {Volume is described as a value between 0 and 1, with 0 indicating minimum
  272.   volume and 1 indicating maximum volume; if the device doesn't support
  273.   software control of volume, then a value of unimpErr is returned, indicating
  274.   that these functions are not supported by the device}
  275. FUNCTION AudioGetVolume(ac: ComponentInstance; whichChannel: INTEGER; VAR volume: ShortFixed): ComponentResult;
  276.     {$IFC NOT GENERATINGCFM}
  277.     INLINE $2F3C, 6, 0, $7000, $A82A;
  278.     {$ENDC}
  279. FUNCTION AudioSetVolume(ac: ComponentInstance; whichChannel: INTEGER; volume: ShortFixed): ComponentResult;
  280.     {$IFC NOT GENERATINGCFM}
  281.     INLINE $2F3C, 4, 1, $7000, $A82A;
  282.     {$ENDC}
  283. {If the device doesn't support software control of mute, then a value of unimpErr is}
  284. {returned, indicating that these functions are not supported by the device}
  285. FUNCTION AudioGetMute(ac: ComponentInstance; whichChannel: INTEGER; VAR mute: INTEGER): ComponentResult;
  286.     {$IFC NOT GENERATINGCFM}
  287.     INLINE $2F3C, 6, 2, $7000, $A82A;
  288.     {$ENDC}
  289. FUNCTION AudioSetMute(ac: ComponentInstance; whichChannel: INTEGER; mute: INTEGER): ComponentResult;
  290.     {$IFC NOT GENERATINGCFM}
  291.     INLINE $2F3C, 4, 3, $7000, $A82A;
  292.     {$ENDC}
  293. {AudioSetToDefaults causes the associated device to reset its volume and mute values}
  294. {(and perhaps other characteristics, e.g. attenuation) to "factory default" settings}
  295. FUNCTION AudioSetToDefaults(ac: ComponentInstance): ComponentResult;
  296.     {$IFC NOT GENERATINGCFM}
  297.     INLINE $2F3C, 0, 4, $7000, $A82A;
  298.     {$ENDC}
  299. {This routine is required; it must be implemented by all audio components}
  300. FUNCTION AudioGetInfo(ac: ComponentInstance; info: AudioInfoPtr): ComponentResult;
  301.     {$IFC NOT GENERATINGCFM}
  302.     INLINE $2F3C, 4, 5, $7000, $A82A;
  303.     {$ENDC}
  304. FUNCTION AudioGetBass(ac: ComponentInstance; whichChannel: INTEGER; VAR bass: INTEGER): ComponentResult;
  305.     {$IFC NOT GENERATINGCFM}
  306.     INLINE $2F3C, 6, 6, $7000, $A82A;
  307.     {$ENDC}
  308. FUNCTION AudioSetBass(ac: ComponentInstance; whichChannel: INTEGER; bass: INTEGER): ComponentResult;
  309.     {$IFC NOT GENERATINGCFM}
  310.     INLINE $2F3C, 4, 7, $7000, $A82A;
  311.     {$ENDC}
  312. FUNCTION AudioGetTreble(ac: ComponentInstance; whichChannel: INTEGER; VAR Treble: INTEGER): ComponentResult;
  313.     {$IFC NOT GENERATINGCFM}
  314.     INLINE $2F3C, 6, 8, $7000, $A82A;
  315.     {$ENDC}
  316. FUNCTION AudioSetTreble(ac: ComponentInstance; whichChannel: INTEGER; Treble: INTEGER): ComponentResult;
  317.     {$IFC NOT GENERATINGCFM}
  318.     INLINE $2F3C, 4, 9, $7000, $A82A;
  319.     {$ENDC}
  320. FUNCTION AudioGetOutputDevice(ac: ComponentInstance; VAR outputDevice: Component): ComponentResult;
  321.     {$IFC NOT GENERATINGCFM}
  322.     INLINE $2F3C, 4, 10, $7000, $A82A;
  323.     {$ENDC}
  324. {This is routine is private to the AudioVision component.  It enables the watching of the mute key.}
  325. FUNCTION AudioMuteOnEvent(ac: ComponentInstance; muteOnEvent: INTEGER): ComponentResult;
  326.     {$IFC NOT GENERATINGCFM}
  327.     INLINE $2F3C, 2, 129, $7000, $A82A;
  328.     {$ENDC}
  329. CONST
  330.     uppSoundParamProcInfo = $000000D0; { FUNCTION (4 byte param): 1 byte result; }
  331.  
  332. FUNCTION NewSoundParamProc(userRoutine: SoundParamProcPtr): SoundParamUPP;
  333.     {$IFC NOT GENERATINGCFM }
  334.     INLINE $2E9F;
  335.     {$ENDC}
  336.  
  337. FUNCTION CallSoundParamProc(VAR pb: SoundParamBlockPtr; userRoutine: SoundParamUPP): BOOLEAN;
  338.     {$IFC NOT GENERATINGCFM}
  339.     INLINE $205F, $4E90;
  340.     {$ENDC}
  341.  
  342. {$ALIGN RESET}
  343. {$POP}
  344.  
  345. {$SETC UsingIncludes := SoundComponentsIncludes}
  346.  
  347. {$ENDC} {__SOUNDCOMPONENTS__}
  348.  
  349. {$IFC NOT UsingIncludes}
  350.  END.
  351. {$ENDC}
  352.